﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.DTO;
using DXApplicationTangche.UC.成品出库单.service;
using DXApplicationTangche.UC.订单一览新.订单预览新.service;
using mendian;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.UC.抖音出入库.Service
{
    public class 抖音订单Service
    {
        /// <summary>
        /// 抖音订单一览
        /// </summary>
        /// <param name="page"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public static List<DouyinOrderDTO> getDouyinOrderAll(String start, String end)
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinOrderDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinOrderAll?start=" + start
                        + "&end=" + end
                    )
                );
        }
        public static void saveDouyinOrderReturn(List<DouyinOrderReturnDTO> douyinOrderReturnDTOs)
        {
            String xx = FunctionHelper.JsonSerialization(douyinOrderReturnDTOs);
            RestCall.PostHttp(
                URL.接口url1 + "/douyin/saveDouyinOrderReturn",
                FunctionHelper.JsonSerialization(douyinOrderReturnDTOs)
                );
        }
        /// <summary>
        /// 取抖音收款财务信息
        /// </summary>
        /// <param name="start"></param>
        /// <returns></returns>
        public static DouyinFinancialQueryFacadeDTO getDouyinFinancialSimpleAll(String start)
        {
            return
                FunctionHelper.JsonDeserialization<DouyinFinancialQueryFacadeDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinFinancialSimpleAll?accountingType=" + start
                    )
                );
        }
        /// <summary>
        /// 根据时间戳取收款一览
        /// </summary>
        /// <param name="start"></param>
        /// <param name="dataStr"></param>
        /// <returns></returns>
        public static DouyinFinancialQueryFacadeDTO getDouyinFinancialSimple(String start,String dataStr)
        {
            return
                FunctionHelper.JsonDeserialization<DouyinFinancialQueryFacadeDTO>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinFinancialSimple?accountingType=" + start
                                            + "&dataStr="+ dataStr
                    )
                );
        }

        /// <summary>
        /// 抖音发货出库对账
        /// </summary>
        /// <param name="start"></param>
        /// <returns></returns>
        public static List<DouyinStockOutCheckDTO> getDouyinOrderStockOutByDateStr(String dateStr)
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinStockOutCheckDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinOrderStockOutByDateStr?dateStr=" + dateStr
                    )
                );
        }
        /// <summary>
        /// 取抖音订单一览
        /// </summary>
        /// <param name="dateStr"></param>
        /// <returns></returns>
        public static List<DouyinOrderViewDTO> getDouyinOrderViewByDataStr(String start, String end)
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinOrderViewDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinOrderViewByDataStr?start=" + start
                        + "&end=" + end
                    )
                );
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static List<ViewDouyinOrderAfterSaleDao> getDouyinOrderAfterSaleList()
        {
            return
                FunctionHelper.JsonDeserialization<List<ViewDouyinOrderAfterSaleDao>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinOrderAfterSaleList"
                    )
                );
        }
        /// <summary>
        /// 抖音发运一览
        /// </summary>
        /// <returns></returns>
        public static List<DouyinDeliveryReportDTO> getViewDouyinDeliveryReportAll()
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinDeliveryReportDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getViewDouyinDeliveryReportAll"
                    )
                );
        }

        public static List<DouyinOrderStockUpSummaryDTO> getDouyinOrderPlan()
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinOrderStockUpSummaryDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinOrderPlan"
                    )
                );
        }
        public static List<DouyinOrderStockUpSummaryDTO> getDouyinStockInfo()
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinOrderStockUpSummaryDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getDouyinStockInfo"
                    )
                );
        }
        /// <summary>
        /// python表导入时间
        /// </summary>
        /// <returns></returns>
        public static DateTime getPythonImportRecordDateTime(String tableName)
        {
            return
                FunctionHelper.JsonDeserialization<DateTime>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getPythonImportRecordDateTime?tableName=" + tableName
                    )
                );
        }

        /// <summary>
        ///昨日下单的抖音备货一览
        /// </summary>
        /// <returns></returns>
        public static List<DouyinOrderStockUpDTO> getYesterdayDouyinOrderStockUps()
        {
            return
                FunctionHelper.JsonDeserialization<List<DouyinOrderStockUpDTO>>(
                    RestCall.httpGetMethod(
                        URL.接口url1 + "/douyin/getYesterdayDouyinOrderStockUps"
                    )
                );
        }
    }

    /// <summary>
    /// 抖音备货dto
    /// </summary>
    public class DouyinOrderStockUpDTO
    {
        public String subOrderNo { get; set; }  //  子订单编号   "   4873777077591317897"
        public String skuId { get; set; }   //规格ID(SKUID)
        public String barcode { get; set; }
        public String styleSizeCd { get; set; } //  尺码
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public int quantity { get; set; }   //  商品数量    2
        public Double unitPrice { get; set; }   //  商品单价    69
        private Double payable { get; set; } //  订单应付金额  99
        public Double discount { get; set; }    //  优惠总金额   39.04
        public String inventoryNo { get; set; } //  选购商品    "   【春衫定制】纯色大圆领绸丽绒打底衫保暖吊带背心女21F69"
        public String spec { get; set; }    //  商品规格    "   白色1950_01{get;set;}2XL（140~150斤）"

        public String orderStatus { get; set; } //  订单状态    备货中
        public DateTime arrivalDate { get; set; }   //  承诺发货时间  "   2021-12-16 21:53:34"
        public DateTime orderDate { get; set; }   //    订单提交时间  "   2021-12-07 14:49:39"
        public DouyinOrderStockUpDTO()
        {

        }
    }
    public class DouyinOrderStockUpSummaryDTO
    {
        public String styleSizeCd { get; set; } //  尺码
        public Double euroSize { get; set; }    //  排序用欧洲尺码
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public String inventoryNo { get; set; } //	选购商品	"	【春衫定制】纯色大圆领绸丽绒打底衫保暖吊带背心女21F69"
        public String spec { get; set; }    //	商品规格	"	白色1950_01{get;set;}2XL（140~150斤）"
        /// <summary>
        /// 数量合计
        /// </summary>
        public int threeDays { get; set; }  //  未来3天发货量
        public int sevenDays { get; set; }  //  未来三到七天发货量
        public int overSevenDays { get; set; }  //  七天以后发货量
        public int totlaQuantity { get; set; }   //	总数量
        public int orderQuantity { get; set; }  //  订单数量
        public int washingMarkQuantity { get; set; }   //	水洗数量
        public int wipStockInQuantity { get; set; }  //  生产批入库数量

        public String imageUrl { get; set; }     //  图片url
        //  工序数量
        public int semiCheckCount { get; set; } //  半成品检查
        public int finishCheckCount { get; set; }   //  成品检查
        public int dingsuoCount { get; set; }   //  钉锁
        public int shoufengCount { get; set; }   //  手缝

        //  在库数量
        public int preStockIn { get; set; }  //  预库存
        public int garmentStockIn { get; set; }  //  成品库存
        public int kaidanStockIn { get; set; }  //  凯丹库存
        public int baiweinianStockIn { get; set; }  //  柏威年库存
        //  价格
        public Double salePrice { get; set; }   //  吊牌价
        public Double onlineSalePrice { get; set; } //  电商零售价
        public DouyinOrderStockUpSummaryDTO()
        {

        }
    }
    /// <summary>
    /// 抖音发货出库对账
    /// </summary>
    public class DouyinStockOutCheckDTO
    {
        public String styleSizeCd { get; set; } //  尺码
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public int douyinStockOutQuantity { get; set; }  //  抖音发货数量
        public long inventoryStockOutQuantity { get; set; }   //  库存发货数量
        public long inventoryStockInQuantity { get; set; }   //  库存回库数量

        public List<StockInOutDetailDTO> stockOutDetailDTOList { get; set; } = new List<StockInOutDetailDTO>();
        public List<StockInOutDetailDTO> stockInDetailDTOList { get; set; } = new List<StockInOutDetailDTO>();
        public List<ViewDouyinOrderDeliverDTO> viewDouyinOrderDeliverDTOS { get; set; } = new List<ViewDouyinOrderDeliverDTO>();
        public DouyinStockOutCheckDTO()
        {

        }
    }
    public class DouyinDeliveryReportDTO
    {
        public String subOrderNo { get; set; }
        public String orderno { get; set; }
        public String orderstatus { get; set; }
        public DateTime orderdate { get; set; }
        public DateTime createdate { get; set; }
        public String inventoryno { get; set; }
        public String spec { get; set; }
        public String stylecode { get; set; }
        public String materialcode { get; set; }
        public String stylesizecd { get; set; }
        public int quantity { get; set; }
        public Double unitprice { get; set; }
        public Double payable { get; set; }
        public String paymenttype { get; set; }
        public String returndeliverytime { get; set; }
        public DouyinDeliveryReportDTO() { }

    }
    public class ViewDouyinOrderDeliverDTO
    {
        public String subOrderNo { get; set; }  // 子订单编号 " 4873777077591317897"
        /*
         *  核心维度
         */
        public Boolean saleFund { get; set; } //  是否收款
        public Boolean returnFund { get; set; } //  是否退款
        public Boolean goodsReturn { get; set; } //  退款是否收到货
        /*
         *  sku数据
         */
        public String skuId { get; set; }   //规格ID(SKUID)
        public String barcode { get; set; }
        public String styleSizeCd { get; set; } //  尺码
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public DateTime createDate { get; set; }
        /**
         * 订单维度和度量数据
         */
        public int dateStamp { get; set; }    //  订单提交时间戳，对应下单
        public int orderCompleteDateStamp { get; set; }// 订单完成时间戳，对应已完成
        public int quantity { get; set; }   // 商品数量 2
        public Double unitPrice { get; set; }   // 商品单价 69
        public Double payable { get; set; } // 订单应付金额 99
        public Double deliveryPrice { get; set; }   // 运费 0
        public Double discount { get; set; }    // 优惠总金额 39.04
        public Double platformDiscount { get; set; }    // 平台优惠 -
        public Double shoPriceModify { get; set; }  // 商家改价 0
        public Double paymentDiscount { get; set; } // 支付优惠 0.04
        public Double hongbaoDiscount { get; set; } // 红包抵扣 0
        public Double commission { get; set; }   // 手续费 0
        /**
         * 退货维度和度量
         */
        public int afterSaleDateStamp { get; set; } //  退货时间戳，对应已关闭及退货明细
        public Double returnPrice { get; set; } //退商品金额（元）
        public Double returnDeliveryPrice { get; set; } //退运费金额（元）
        public Double returnPayable { get; set; } //退支付优惠（元）
        public Double returnTaxCharge { get; set; }   //退税费金额（元）
        /**
         * 发运数据
         */
        public int delieveryDateStamp { get; set; } //  发运时间戳
        public Boolean delieveryforcebalance { get; set; }  //  发运账是否强行平账
        public ViewDouyinOrderDeliverDTO()
        {

        }
    }

    public class DouyinFinancialQueryFacadeDTO
    {
        public List<DouyinFinancialSimpleDTO> douyinFinancialSimpleDTOS { get; set; } = new List<DouyinFinancialSimpleDTO>();
        public List<ViewDouyinOrderSaleFundDTO> viewDouyinOrderSaleFundDTOList { get; set; } = new List<ViewDouyinOrderSaleFundDTO>();
        public DouyinFinancialQueryFacadeDTO()
        {

        }

        public DouyinFinancialQueryFacadeDTO(List<DouyinFinancialSimpleDTO> douyinFinancialSimpleDTOS, List<ViewDouyinOrderSaleFundDTO> viewDouyinOrderSaleFundDTOList)
        {
            this.douyinFinancialSimpleDTOS = douyinFinancialSimpleDTOS;
            this.viewDouyinOrderSaleFundDTOList = viewDouyinOrderSaleFundDTOList;
        }
    }
    public class DouyinFinancialSimpleDTO
    {
        public String dateStr { get; set; }
        public Double payable { get; set; }
        public String accountingType { get; set; }  //  收付款账户类型
        public DouyinFinancialSimpleDTO()
        {

        }

        public DouyinFinancialSimpleDTO(string dateStr, double payable, string accountingType)
        {
            this.dateStr = dateStr;
            this.payable = payable;
            this.accountingType = accountingType;
        }
    }
    public class ViewDouyinOrderSaleFundDTO
    {
        public String subOrderNo { get; set; }  // 子订单编号 " 4873777077591317897"
        public int dateStamp { get; set; }    //  订单时间戳
        public int afterSaleDateStamp { get; set; } //  退货时间戳
        public String orderNo { get; set; } // 主订单编号 " 4873777077591317897"
        public String inventoryNo { get; set; } // 选购商品 " 【春衫定制】纯色大圆领绸丽绒打底衫保暖吊带背心女21F69"
        public String spec { get; set; }    // 商品规格 " 白色1950_01{get;set;}2XL（140~150斤）"
        public int quantity { get; set; }   // 商品数量 2
        public String productId { get; set; }   // 商品ID " 3512236491768224471"
        public String shopNo { get; set; }  // 商家编码
        public Double unitPrice { get; set; }   // 商品单价 69
        public Double payable { get; set; } // 订单应付金额 99
        public Double deliveryPrice { get; set; }   // 运费 0
        public Double discount { get; set; }    // 优惠总金额 39.04
        public Double platformDiscount { get; set; }    // 平台优惠 -
        public String shopDicountDesc { get; set; } // 商家优惠 两件99-39.00
        public String broadcastDicountDesc { get; set; }    // 主播优惠 -
        public Double shoPriceModify { get; set; }  // 商家改价 0
        public Double paymentDiscount { get; set; } // 支付优惠 0.04
        public Double hongbaoDiscount { get; set; } // 红包抵扣 0
        public String paymentType { get; set; } // 支付方式 " 银行卡"
        public Double commission { get; set; }   // 手续费 0
        public String reception { get; set; }   // 收件人 ##XYjykxjZJ9l0yb2IlQWj9ZAhJt2/wXHLNE/BStdE4hhe7369DK6E9kVhCkfDXkla2iWPNWuVt+VY+1Cn3if1bbFedg/oCFYC4N3F*CgkIARCtHCABKAESPgo8mgBetVteQKwns8g3UGaHwrXHe4fl68XdYV4+vlzWgaSK2vbRa5abL7/x4YEElRb5VRL3bgxQUk/5zPlZGgA=#1##
        public String mobile { get; set; }  // 收件人手机号 ##MA0H4Y4/lMuDc64N9mwc3f9zY40TY7NeIUwgblnA3EUQbeSeh+PWtaz0oRNWp3E0qYL3z4V25NdUT9+Z3LHc3UmQ21r+5f9/a1GQkRc=*CgkIARCtHCABKAESPgo8ttVBfFY2naf5ypMRM9Q88gDX4v1bsP7E9jhH2D3zmhbZxLthAHLVE0pC6SRo3wyqq4YRtxWlMw+FMKykGgA=#1##
        public String province { get; set; }    // 省 北京市
        public String city { get; set; }    // 市 北京市
        public String county { get; set; }  // 区 东城区
        public String district { get; set; }    // 街道 崇文门外街道
        public String addressDetail { get; set; }   // 详细地址 ##e8zXa52KkqWmspQFdyhI5VG/ZrdyQgDygU2qLpfOTbni90iNKVqBbjTCQQygDNlzALt0Qlu1DnoklRxYwKbal0lgU8lItd0C3Szuz2l7IdWq2c+vTsAw4Wwjsy9gCgIHgX8=*CgkIARCtHCABKAESPgo8u6oRux4rQmHhMXiDilcJFYoL+WCtobpmaxXehCtWHIQnR/7q64qbJkFWY0e5H+Nv4HACnVJHrCGGp7KaGgA=#1##
        public String addressModify { get; set; }   // 是否修改过地址 否
        public String buyer { get; set; }   // 买家留言
        public DateTime orderDate { get; set; }   // 订单提交时间 " 2021-12-07 14:49:39"
        public String flagColor { get; set; }   // 旗帜颜色 灰色
        public String shopMemo { get; set; }    // 商家备注
        public DateTime orderCompleteDate { get; set; }// 订单完成时间
        public DateTime paymentDate { get; set; }   // 支付完成时间 " 2021-12-07 14:49:49"
        public String appChannel { get; set; }  // APP渠道 抖音极速版
        public String trafficSource { get; set; }   // 流量来源 小店自卖
        public String orderStatus { get; set; } // 订单状态 备货中
        public DateTime arrivalDate { get; set; }   // 承诺发货时间 " 2021-12-16 21:53:34"
        public String orderType { get; set; }   // 订单类型 普通订单
        public String lubanPageId { get; set; } // 鲁班落地页ID " 0"
        public String wiseManId { get; set; }   // 达人ID " 0"
        public String wiseManName { get; set; } // 达人昵称
        public String shopId { get; set; }   // 所属门店ID -
        public String postSaleStatus { get; set; }  // 售后状态 -
        public String cancelReason { get; set; }    // 取消原因
        public DateTime preDeliveryDate { get; set; }   // 预约发货时间 -
        public String stockId { get; set; } // 仓库ID " -"
        public String stockName { get; set; }   // 仓库名称 " -"
        public String anxin { get; set; }   // 是否安心购 是
        public String advertisingChannel { get; set; }  // 广告渠道 无
        public String deliveryHost { get; set; }    // 发货主体 -
        public String deliveryHostDetail { get; set; }  // 发货主体明细 -

        /*
         *  sku数据
         */
        public String skuId { get; set; }   //规格ID(SKUID)
        public String barcode { get; set; }

        public String styleSizeCd { get; set; } //  尺码
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public DateTime createDate { get; set; }
        /*
         *  退货信息
         */
        public String returnOrderNo { get; set; }    //售后单号
        public Double taxCharge { get; set; }   //商品税费（元）
        public String deliveryStatus { get; set; }  //商品发货状态
        public String afterSaleType { get; set; }   //售后类型
        public Double returnPrice { get; set; } //退商品金额（元）
        public Double returnDeliveryPrice { get; set; } //退运费金额（元）
        public Double returnPayable { get; set; } //退支付优惠（元）
        public Double returnTaxCharge { get; set; }   //退税费金额（元）
        public String afterSaleStatus { get; set; } //售后状态
        public DateTime afterSaleApplyTime { get; set; }    //售后申请时间
        public String returnType { get; set; }  //退款方式
        public Boolean voucherUpload { get; set; }  //是否已上传退款凭证
        public String afterSaleReason { get; set; } //售后原因
        public String logisticsOrderNo { get; set; }  //退货物流单号
        public String returnException { get; set; } //退货异常
        public DateTime returnDeliveryTime { get; set; } //退货发货时间
        public String returnDeliveryCorp { get; set; }  //退货物流公司
        public DateTime autoHandleTime { get; set; }    //自动处理截止时间
        public DateTime afterSaleApproveTime { get; set; }  //同意售后申请时间
        public DateTime refundTime { get; set; }    //退款成功时间
        public DateTime afterSaleClodeTime { get; set; }    //售后关闭时间
        public String storeReturnAddress { get; set; }  //商家退货地址
        public String storeContact { get; set; }    //商家退货联系人姓名
        public String storeReturnContact { get; set; }  //商家退货联系人电话
        public String customerServiceArbitration { get; set; }  //客服仲裁
        public String dissensionInCharge { get; set; }  //纠纷责任方
        public Boolean swiftRefund { get; set; }    //是否极速退款
        public String logisticsStatus { get; set; } //正向物流状态
        public Boolean refundAfterSignRejection { get; set; }   //是否拒签后退款
        /*
         *  核心维度
         */
        public Boolean saleFund { get; set; } //  是否收款
        public Boolean returnFund { get; set; } //  是否退款
        public Boolean goodsReturn { get; set; } //  退款是否收到货
        public ViewDouyinOrderSaleFundDTO()
        {

        }

        public ViewDouyinOrderSaleFundDTO(string subOrderNo, int dateStamp, int afterSaleDateStamp, string orderNo, string inventoryNo, string spec, int quantity, string productId, string shopNo, double unitPrice, double payable, double deliveryPrice, double discount, double platformDiscount, string shopDicountDesc, string broadcastDicountDesc, double shoPriceModify, double paymentDiscount, double hongbaoDiscount, string paymentType, double commission, string reception, string mobile, string province, string city, string county, string district, string addressDetail, string addressModify, string buyer, DateTime orderDate, string flagColor, string shopMemo, DateTime orderCompleteDate, DateTime paymentDate, string appChannel, string trafficSource, string orderStatus, DateTime arrivalDate, string orderType, string lubanPageId, string wiseManId, string wiseManName, string shopId, string postSaleStatus, string cancelReason, DateTime preDeliveryDate, string stockId, string stockName, string anxin, string advertisingChannel, string deliveryHost, string deliveryHostDetail, string skuId, string barcode, string styleSizeCd, string styleCode, string materialCode, DateTime createDate, string returnOrderNo, double taxCharge, string deliveryStatus, string afterSaleType, double returnPrice, double returnDeliveryPrice, double returnPayable, double returnTaxCharge, string afterSaleStatus, DateTime afterSaleApplyTime, string returnType, bool voucherUpload, string afterSaleReason, string logisticsOrderNo, string returnException, DateTime returnDeliveryTime, string returnDeliveryCorp, DateTime autoHandleTime, DateTime afterSaleApproveTime, DateTime refundTime, DateTime afterSaleClodeTime, string storeReturnAddress, string storeContact, string storeReturnContact, string customerServiceArbitration, string dissensionInCharge, bool swiftRefund, string logisticsStatus, bool refundAfterSignRejection, bool saleFund, bool returnFund, bool goodsReturn)
        {
            this.subOrderNo = subOrderNo;
            this.dateStamp = dateStamp;
            this.afterSaleDateStamp = afterSaleDateStamp;
            this.orderNo = orderNo;
            this.inventoryNo = inventoryNo;
            this.spec = spec;
            this.quantity = quantity;
            this.productId = productId;
            this.shopNo = shopNo;
            this.unitPrice = unitPrice;
            this.payable = payable;
            this.deliveryPrice = deliveryPrice;
            this.discount = discount;
            this.platformDiscount = platformDiscount;
            this.shopDicountDesc = shopDicountDesc;
            this.broadcastDicountDesc = broadcastDicountDesc;
            this.shoPriceModify = shoPriceModify;
            this.paymentDiscount = paymentDiscount;
            this.hongbaoDiscount = hongbaoDiscount;
            this.paymentType = paymentType;
            this.commission = commission;
            this.reception = reception;
            this.mobile = mobile;
            this.province = province;
            this.city = city;
            this.county = county;
            this.district = district;
            this.addressDetail = addressDetail;
            this.addressModify = addressModify;
            this.buyer = buyer;
            this.orderDate = orderDate;
            this.flagColor = flagColor;
            this.shopMemo = shopMemo;
            this.orderCompleteDate = orderCompleteDate;
            this.paymentDate = paymentDate;
            this.appChannel = appChannel;
            this.trafficSource = trafficSource;
            this.orderStatus = orderStatus;
            this.arrivalDate = arrivalDate;
            this.orderType = orderType;
            this.lubanPageId = lubanPageId;
            this.wiseManId = wiseManId;
            this.wiseManName = wiseManName;
            this.shopId = shopId;
            this.postSaleStatus = postSaleStatus;
            this.cancelReason = cancelReason;
            this.preDeliveryDate = preDeliveryDate;
            this.stockId = stockId;
            this.stockName = stockName;
            this.anxin = anxin;
            this.advertisingChannel = advertisingChannel;
            this.deliveryHost = deliveryHost;
            this.deliveryHostDetail = deliveryHostDetail;
            this.skuId = skuId;
            this.barcode = barcode;
            this.styleSizeCd = styleSizeCd;
            this.styleCode = styleCode;
            this.materialCode = materialCode;
            this.createDate = createDate;
            this.returnOrderNo = returnOrderNo;
            this.taxCharge = taxCharge;
            this.deliveryStatus = deliveryStatus;
            this.afterSaleType = afterSaleType;
            this.returnPrice = returnPrice;
            this.returnDeliveryPrice = returnDeliveryPrice;
            this.returnPayable = returnPayable;
            this.returnTaxCharge = returnTaxCharge;
            this.afterSaleStatus = afterSaleStatus;
            this.afterSaleApplyTime = afterSaleApplyTime;
            this.returnType = returnType;
            this.voucherUpload = voucherUpload;
            this.afterSaleReason = afterSaleReason;
            this.logisticsOrderNo = logisticsOrderNo;
            this.returnException = returnException;
            this.returnDeliveryTime = returnDeliveryTime;
            this.returnDeliveryCorp = returnDeliveryCorp;
            this.autoHandleTime = autoHandleTime;
            this.afterSaleApproveTime = afterSaleApproveTime;
            this.refundTime = refundTime;
            this.afterSaleClodeTime = afterSaleClodeTime;
            this.storeReturnAddress = storeReturnAddress;
            this.storeContact = storeContact;
            this.storeReturnContact = storeReturnContact;
            this.customerServiceArbitration = customerServiceArbitration;
            this.dissensionInCharge = dissensionInCharge;
            this.swiftRefund = swiftRefund;
            this.logisticsStatus = logisticsStatus;
            this.refundAfterSignRejection = refundAfterSignRejection;
            this.saleFund = saleFund;
            this.returnFund = returnFund;
            this.goodsReturn = goodsReturn;
        }
    }
    public class DouyinOrderReturnDTO
    {
        public String returnOrderNo { get; set; }    //售后单号
        public String orderNo { get; set; }  //订单号
        public String subOrderNo { get; set; }  //商品单号
        public String inventoryNo { get; set; } //商品名称
        public String productId { get; set; }   //商品ID
        public String payable { get; set; } //应付金额（元）
        public String deliveryPrice { get; set; }   //商品运费（元）
        public String paymentDiscount { get; set; }//支付优惠（元）
        public String taxCharge { get; set; }   //商品税费（元）
        public String deliveryStatus { get; set; }  //商品发货状态
        public String afterSaleType { get; set; }   //售后类型
        public String returnPrice { get; set; } //退商品金额（元）
        public String returnDeliveryPrice { get; set; } //退运费金额（元）
        public String returnPayable { get; set; } //退支付优惠（元）
        public String returnTaxCharge { get; set; }   //退税费金额（元）
        public String afterSaleStatus { get; set; } //售后状态
        public String afterSaleApplyTime { get; set; }    //售后申请时间
        public String returnType { get; set; }  //退款方式
        public String voucherUpload { get; set; }  //是否已上传退款凭证
        public String afterSaleReason { get; set; } //售后原因
        public String logisticsOrderNo { get; set; }  //退货物流单号
        public String returnException { get; set; } //退货异常
        public String returnDeliveryTime { get; set; } //退货发货时间
        public String returnDeliveryCorp { get; set; }  //退货物流公司
        public String autoHandleTime { get; set; }    //自动处理截止时间
        public String afterSaleApproveTime { get; set; }  //同意售后申请时间
        public String refundTime { get; set; }    //退款成功时间
        public String afterSaleClodeTime { get; set; }    //售后关闭时间
        public String storeReturnAddress { get; set; }  //商家退货地址
        public String storeContact { get; set; }    //商家退货联系人姓名
        public String storeReturnContact { get; set; }  //商家退货联系人电话
        public String customerServiceArbitration { get; set; }  //客服仲裁
        public String dissensionInCharge { get; set; }  //纠纷责任方
        public String swiftRefund { get; set; }    //是否极速退款
        public String logisticsStatus { get; set; } //正向物流状态
        public String refundAfterSignRejection { get; set; }   //是否拒签后退款
        public DouyinOrderReturnDTO()
        {

        }

        public DouyinOrderReturnDTO(string returnOrderNo, string orderNo, string subOrderNo, string inventoryNo, string productId, string payable, string deliveryPrice, string paymentDiscount, string taxCharge, string deliveryStatus, string afterSaleType, string returnPrice, string returnDeliveryPrice, string returnPayable, string returnTaxCharge, string afterSaleStatus, string afterSaleApplyTime, string returnType, string voucherUpload, string afterSaleReason, string logisticsOrderNo, string returnException, string returnDeliveryTime, string returnDeliveryCorp, string autoHandleTime, string afterSaleApproveTime, string refundTime, string afterSaleClodeTime, string storeReturnAddress, string storeContact, string storeReturnContact, string customerServiceArbitration, string dissensionInCharge, string swiftRefund, string logisticsStatus, string refundAfterSignRejection)
        {
            this.returnOrderNo = returnOrderNo;
            this.orderNo = orderNo;
            this.subOrderNo = subOrderNo;
            this.inventoryNo = inventoryNo;
            this.productId = productId;
            this.payable = payable;
            this.deliveryPrice = deliveryPrice;
            this.paymentDiscount = paymentDiscount;
            this.taxCharge = taxCharge;
            this.deliveryStatus = deliveryStatus;
            this.afterSaleType = afterSaleType;
            this.returnPrice = returnPrice;
            this.returnDeliveryPrice = returnDeliveryPrice;
            this.returnPayable = returnPayable;
            this.returnTaxCharge = returnTaxCharge;
            this.afterSaleStatus = afterSaleStatus;
            this.afterSaleApplyTime = afterSaleApplyTime;
            this.returnType = returnType;
            this.voucherUpload = voucherUpload;
            this.afterSaleReason = afterSaleReason;
            this.logisticsOrderNo = logisticsOrderNo;
            this.returnException = returnException;
            this.returnDeliveryTime = returnDeliveryTime;
            this.returnDeliveryCorp = returnDeliveryCorp;
            this.autoHandleTime = autoHandleTime;
            this.afterSaleApproveTime = afterSaleApproveTime;
            this.refundTime = refundTime;
            this.afterSaleClodeTime = afterSaleClodeTime;
            this.storeReturnAddress = storeReturnAddress;
            this.storeContact = storeContact;
            this.storeReturnContact = storeReturnContact;
            this.customerServiceArbitration = customerServiceArbitration;
            this.dissensionInCharge = dissensionInCharge;
            this.swiftRefund = swiftRefund;
            this.logisticsStatus = logisticsStatus;
            this.refundAfterSignRejection = refundAfterSignRejection;
        }
    }
    public class DouyinMTSOrderDTO
    {
        public String refBarcode { get; set; } //样衣barcode
        public String styleNameCn { get; set; } //款式名称
        public String materialCode { get; set; } //面料号
        public String styleSizeCd { get; set; } //尺码
        public int quantity { get; set; } //下单数量
        public int price { get; set; } //下单数量
        public OrderCommitDTO返回 orderCommitDTO { get; set; } = new OrderCommitDTO返回();
        public DouyinMTSOrderDTO()
        {

        }

        public DouyinMTSOrderDTO(string refBarcode, string styleNameCn, string materialCode, string styleSizeCd, int quantity, int price)
        {
            this.refBarcode = refBarcode;
            this.styleNameCn = styleNameCn;
            this.materialCode = materialCode;
            this.styleSizeCd = styleSizeCd;
            this.quantity = quantity;
            this.price = price;
        }
        public DouyinMTSOrderDTO(DouyinMaterialDTO douyinMaterialDTO)
        {
            this.refBarcode = douyinMaterialDTO.refBarcode;
            this.styleNameCn = douyinMaterialDTO.styleNameCn;
            this.materialCode = douyinMaterialDTO.materialCode;
            this.styleSizeCd = douyinMaterialDTO.styleSizeCd;
        }
    }
    public class DouyinOrderCountDTO
    {
        public String refBarcode { get; set; } //样衣barcode
        public String styleCode { get; set; } //款式名称
        public String materialCode { get; set; } //面料号
        public String styleSizeCd { get; set; } //尺码
        public int quantity { get; set; } //下单数量
        public DouyinOrderCountDTO()
        {

        }

        public DouyinOrderCountDTO(string refBarcode, string styleCode, string materialCode, string styleSizeCd, int quantity)
        {
            this.refBarcode = refBarcode;
            this.styleCode = styleCode;
            this.materialCode = materialCode;
            this.styleSizeCd = styleSizeCd;
            this.quantity = quantity;
        }
        public DouyinOrderCountDTO(DouyinOrderDTO douyinOrderDTO)
        {
            this.refBarcode = douyinOrderDTO.barcode;
            this.styleCode = douyinOrderDTO.styleCode;
            this.materialCode = douyinOrderDTO.materialCode;
            this.styleSizeCd = douyinOrderDTO.styleSizeCd;
            this.quantity = douyinOrderDTO.quantity;
        }
    }
    public class DouyinOrderRequestDTO
    {
        public String refBarcode { get; set; } //样衣barcode
        public String styleCode { get; set; } //款式名称
        public String materialCode { get; set; } //面料号
        public String styleSizeCd { get; set; } //尺码
        public int quantity { get; set; } //下单数量
        public int actualOrderQuantity { get; set; } //实际下单数量
        public DouyinOrderRequestDTO()
        {

        }

        public DouyinOrderRequestDTO(string refBarcode, string styleCode, string materialCode, string styleSizeCd, int quantity, int actualOrderQuantity)
        {
            this.refBarcode = refBarcode;
            this.styleCode = styleCode;
            this.materialCode = materialCode;
            this.styleSizeCd = styleSizeCd;
            this.quantity = quantity;
            this.actualOrderQuantity = actualOrderQuantity;
        }
        //DouyinOrderDTO douyinOrderDTO
        public DouyinOrderRequestDTO(DouyinOrderDTO douyinOrderDTO)
        {
            this.refBarcode = douyinOrderDTO.barcode;
            this.styleCode = douyinOrderDTO.styleCode;
            this.materialCode = douyinOrderDTO.materialCode;
            this.styleSizeCd = douyinOrderDTO.styleSizeCd;
            this.quantity = douyinOrderDTO.quantity;
            this.actualOrderQuantity = douyinOrderDTO.quantity;
        }
        public DouyinOrderRequestDTO(DouyinOrderCountDTO douyinOrderDTO, int quantity)
        {
            this.refBarcode = douyinOrderDTO.refBarcode;
            this.styleCode = douyinOrderDTO.styleCode;
            this.materialCode = douyinOrderDTO.materialCode;
            this.styleSizeCd = douyinOrderDTO.styleSizeCd;
            this.quantity = quantity;
            this.actualOrderQuantity = quantity;
        }
    }
    public class DouyinOrderViewDTO
    {
        public int afterSaleDateStamp { get; set; }
        public String barcode { get; set; }
        public double commission { get; set; }
        public DateTime createDate { get; set; }
        public int dateStamp { get; set; }
        public int delieveryDateStamp { get; set; }
        public Boolean goodsReturn { get; set; }
        public double hongbaoDiscount { get; set; }
        public String materialCode { get; set; }
        public int orderCompleteDateStamp { get; set; }
        public double payable { get; set; }
        public double paymentDiscount { get; set; }
        public double platformDiscount { get; set; }
        public int quantity { get; set; }
        public double returnDeliveryPrice { get; set; }
        public Boolean returnFund { get; set; }
        public double returnPayable { get; set; }
        public double returnPrice { get; set; }
        public double returnTaxCharge { get; set; }
        public double shoPriceModify { get; set; }
        public double unitPrice { get; set; }
        public Boolean saleFund { get; set; }
        public String skuId { get; set; }
        public String styleCode { get; set; }
        public String styleSizeCd { get; set; }
        public String subOrderNo { get; set; }
        public DouyinOrderViewDTO()
        {

        }
    }
    public class ViewDouyinOrderAfterSaleDao
    {
        public String subOrderNo { get; set; }  // 子订单编号  "  4873777077591317897"
                                            //  订单
        public DateTime orderDate { get; set; }   //   订单提交时间 "  2021-12-07 14:49:39"
        public String inventoryNo { get; set; } // 选购商品   "  【春衫定制】纯色大圆领绸丽绒打底衫保暖吊带背心女21F69"
        public String spec { get; set; }    // 商品规格   "  白色1950_01{get;set;}2XL（140~150斤）"
        public int quantity { get; set; }   // 商品数量   2
                                            //  sku数据
        public String barcode { get; set; }
        public String styleCode { get; set; }
        public String materialCode { get; set; }
        public String styleSizeCd { get; set; } //  尺码

        public Double payable { get; set; } // 订单应付金额 99
                                            //  退货
        public int afterSaleDateStamp { get; set; } //  退货时间戳，对应已关闭及退货明细
        public DateTime afterSaleApplyTime { get; set; }    //售后申请时间
        public DateTime afterSaleApproveTime { get; set; }  //同意售后申请时间
        public String afterSaleType { get; set; }   //售后类型
        public String logisticsOrderNo { get; set; }  //退货物流单号
        public DateTime returnDeliveryTime { get; set; } //退货发货时间
                                                     //  发货
        public int deliverDateStamp { get; set; }    //发货时间戳
        public DateTime deliverCreateDate { get; set; }    //发货时间
        public ViewDouyinOrderAfterSaleDao()
        {

        }
    }

    public class DouyinOrderModel
    {
        //查询抖音同款商品订单数量，不外露用private
        private Dictionary<String, DouyinOrderDTO> douyinOrderDTOsWAIT = new Dictionary<String, DouyinOrderDTO>();
        //HOLD状态订单
        public List<DouyinOrderDTO> douyinOrderDTOsHOLD { get; set; } = new List<DouyinOrderDTO>();
        //抖音订单一览
        public List<DouyinOrderDTO> douyinOrderDTOs { get; set; } = new List<DouyinOrderDTO>();
        //整理后的抖音待下单一览
        public List<DouyinOrderRequestDTO> douyinOrderRequestDTOs { get; set; } = new List<DouyinOrderRequestDTO>();
        /// <summary>
        /// 区分抖音WAIT HOLD订单
        /// </summary>
        /// <param name="douyinOrderDTOs">抖音订单一览</param>
        public DouyinOrderModel(String start, String end)
        {
            this.douyinOrderDTOs =
                    抖音订单Service.getDouyinOrderAll(
                        start , end
                        );
            //HOLD
            foreach (DouyinOrderDTO douyinOrderDTO in this.douyinOrderDTOs)
            {
                if ("HOLD".Equals(douyinOrderDTO.status))
                {
                    this.douyinOrderDTOsHOLD.Add(douyinOrderDTO);
                }
            }
            //WAIT状态
            foreach (DouyinOrderDTO douyinOrderDTO in douyinOrderDTOs)
            {
                if ("WAIT".Equals(douyinOrderDTO.status))
                {
                    this.douyinOrderDTOsWAIT.Add(douyinOrderDTO.subOrderNo, douyinOrderDTO);
                }
            }
        }
        //将HOLD状态订单添加至WAIT状态订单
        public DouyinOrderModel build(DouyinOrderDTO douyinOrderDTO)
        {
            this.douyinOrderDTOsWAIT.Add(douyinOrderDTO.subOrderNo, douyinOrderDTO);
            //HOLD订单添加至WAIT订单后，HOLD订单一览移除该订单
            this.douyinOrderDTOsHOLD.Remove(douyinOrderDTO);
            return this;
        }

        public DouyinOrderModel build()
        {
            //取下单数量总计
            //Dictionary key 序列化douyinOrderCountDTO
            Dictionary<String, int> douyinOrderCountDTOs显示 = new Dictionary<String, int>();
            foreach (DouyinOrderDTO douyinOrderDTO in this.douyinOrderDTOsWAIT.Values)
            {
                //取barcode、款号、面料号、尺码               
                DouyinOrderCountDTO douyinOrderCountDTO = new DouyinOrderCountDTO(douyinOrderDTO);
                //包含，更新创建Dictionary
                if (douyinOrderCountDTOs显示.ContainsKey(FunctionHelper.JsonSerialization(douyinOrderCountDTO)))
                {
                    douyinOrderCountDTOs显示[FunctionHelper.JsonSerialization(douyinOrderCountDTO)] += douyinOrderDTO.quantity;
                }
                //不包含，创建Dictionary
                else
                {
                    douyinOrderCountDTOs显示.Add(FunctionHelper.JsonSerialization(douyinOrderCountDTO), douyinOrderDTO.quantity);
                }
            }
            //赋值到下单款式信息新DTO，抖音批量下单提交

            foreach (String douyinOrderCountDTO下单信息 in douyinOrderCountDTOs显示.Keys)
            {
                //款式barcode为空的款，不添加至一览
                if (!String.IsNullOrEmpty(FunctionHelper.JsonDeserialization<DouyinOrderCountDTO>(douyinOrderCountDTO下单信息).refBarcode))
                {
                    this.douyinOrderRequestDTOs.Add(new DouyinOrderRequestDTO(FunctionHelper.JsonDeserialization<DouyinOrderCountDTO>(douyinOrderCountDTO下单信息), douyinOrderCountDTOs显示[douyinOrderCountDTO下单信息]));
                }
            }
            return this;
        }
    }
}
